<template>
	<view class="content">
		<uni-list>
			<view class="" @click="openinfo" v-for="(item,index) in news" :key="index" :data-newsid='item.post_id'>
				<uni-list-item :title="item.title" :note="item.published_at" :thumb="item.author_avatar" thumb-size="lg" ></uni-list-item>
			</view>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				news:[]
			}
		},
		onLoad() {
			uni.request({
				url:'https://unidemo.dcloud.net.cn/api/news',
				method:'GET',
				data:{},
				success: res =>{
					this.news = res.data
				},
				fail: () => {
					
				},
				complete: () => {
					
				}
				
			})
		},
		methods: {
			openinfo(e){
				var newsid = e.currentTarget.dataset.newsid
				uni.navigateTo({
					url: '../info/info?newsid='+newsid,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>
	
</style>
